from rest_framework import serializers
from .models import Nav,Category
# 导航
class NavSerializer(serializers.ModelSerializer):
    class Meta:
        model=Nav
        fields=["name","link","is_http"]

# 首页子菜单
class ChildSerializer(serializers.ModelSerializer):
    class Meta:
        model=Category
        fields=['cname','id']
#         首页分类的序列化器
class CategorySerializer(serializers.ModelSerializer):
    children=ChildSerializer(many=True)
    class Meta:
        model=Category
        fields='__all__'